package com.sh.data.engine.application.model.mapper.integration;


import com.sh.data.engine.application.model.request.integration.*;
import com.sh.data.engine.domain.integration.datasource.model.param.*;
import org.mapstruct.Mapper;

/**
 * @author: mengzheng.mhc
 * @date: 2024/6/5 11:14
 */
@Mapper(componentModel = "spring")
public interface DataSourceSaveParamMapper {

    DataSourceSaveParam requestToParam(DataSourceSaveRequest request);

    DataSourceRdbmsSaveParam requestToRdbmsParam(DataSourceRdbmsSaveRequest request);

    DataSourceHiveSaveParam requestToHiveParam(DataSourceHiveSaveRequest request);

    DataSourceMongoSaveParam requestToMongoParam(DataSourceMongoSaveRequest request);

    DataSourceHDFSSaveParam requestToHDFSParam(DataSourceHDFSSaveRequest request);

    DataSourceIotDBSaveParam requestToIotDBParam(DataSourceIotDBSaveRequest request);

    DataSourceInfluxDBSaveParam requestToInfluxDBParam(DataSourceInfluxDBSaveRequest request);

    default DataSourceSaveParam map(DataSourceSaveRequest request) {
        if (request == null) {
            return requestToParam(request);
        }

        if (request instanceof DataSourceRdbmsSaveRequest) {
            return requestToRdbmsParam((DataSourceRdbmsSaveRequest) request);
        } else if (request instanceof DataSourceHiveSaveRequest) {
            return requestToHiveParam((DataSourceHiveSaveRequest) request);
        } else if (request instanceof DataSourceMongoSaveRequest) {
            return requestToMongoParam((DataSourceMongoSaveRequest) request);
        } else if (request instanceof DataSourceHDFSSaveRequest) {
            return requestToHDFSParam((DataSourceHDFSSaveRequest) request);
        } else if (request instanceof DataSourceIotDBSaveRequest) {
            return requestToIotDBParam((DataSourceIotDBSaveRequest) request);
        } else if (request instanceof DataSourceInfluxDBSaveRequest) {
            return requestToInfluxDBParam((DataSourceInfluxDBSaveRequest) request);
        } else {
            return requestToParam(request);
        }
    }
}
